-- use_spell
-- Created by zouyb Mar/14/2015
-- 使用卷轴

local handle = function(para)
    -- 如果不是在地牢内就忽略
    if not DungeonM.isInDungeon() then
        return;
    end

    -- 已使用的卷轴
    local addPoints = PropStatM.getData1(ME.user, "use_spell_bonus");
    addPoints = addPoints + 1;
    PropStatM.setData1(ME.user, "use_spell_bonus", addPoints);

    -- 触发prop
    local props = PropM.fetchProps(ME.user, "use_spell_bonus");
    for _, prop in ipairs(props) do
        PropM.trigger(ME.user, prop[1], prop[2]);
    end

    props = PropM.fetchProps(ME.user, "use_spell_attrib");
    for _, prop in ipairs(props) do
        if prop[3] == para["skillId"] then
            PropM.trigger(ME.user, prop[1], prop[2]);
        end
    end
end

-- 打开格子事件
EventMgr.register("prop_stat/use_spell", event.USE_SPELL, handle);
